package cn.hg.jfsa.manage.controller.module.ad.validator;

import cn.hg.base.jfinal.validator.BaseValidator;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;

public class AdValidator extends BaseValidator {

	@Override
	protected void validate(Controller c) {
		this.setShortCircuit(true);

		this.validateRequired("ad.status", "statusMsg", "状态为必填！");
		this.validateRequired("ad.placeId", "placeIdMsg", "广告位置为必填！");
		this.validateRequired("ad.type", "typeMsg", "类型为必填！");

		this.validateString("ad.title", 3, 50, "titleMsg", "标题必须填写3到50长度的字符！");

		if (StrKit.notBlank(c.getPara("ad.url"))) {
			this.validateUrl("ad.url", "urlMsg", "跳转链接格式不正确！");
		}
	}

	@Override
	protected void handleError(Controller c) {

	}

}
